#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>

/*
字符串转16进制
*/
//十六进制字符串转换为字节流  
void HexStrToByte(const char* source, uint8_t* dest, int sourceLen)  
{  
    int i;  
    uint8_t highByte, lowByte;  
      
    for (i = 0; i < sourceLen; i += 2)  
    {  
        highByte = source[i];  
        lowByte  = source[i + 1];  
  
        if (highByte >= 'A' && highByte <= 'F')
		{
            highByte -= 0x37;
		}
		else if(highByte >= 'a' && highByte <= 'f')
		{
			highByte -= 0x57;
		}
        else 
		{
            highByte -= '0';  
		}
		
        if (lowByte >= 'A' && lowByte <= 'F')
		{
            lowByte -= 0x37;
		}
		else if(lowByte >= 'a' && lowByte <= 'f')
		{
			lowByte -= 0x57;
		}
        else 
		{
            lowByte -= '0';  
		}
		
        dest[i / 2] = (highByte << 4) | lowByte;  
    }  
    return ;  
}  

//字节流转换为十六进制字符串  
void ByteToHexStr(const uint8_t* source, char* dest, int sourceLen)  
{  
    int i;  
    uint8_t highByte, lowByte;  
  
    for (i = 0; i < sourceLen; i++)  
    {  
        highByte = source[i] >> 4;  
        lowByte = source[i] & 0x0f ;  
  
        if (highByte > 9)  
		{	
            dest[i * 2] = highByte + 0x37;
		}
        else  
		{
			dest[i * 2] = highByte + '0';  
		}		
        if (lowByte > 9)  
		{
			dest[i * 2 + 1] = lowByte + 0x37;  
		}        
		else  
		{    
			dest[i * 2 + 1] = lowByte + '0';
		}
    }  
    return ;  
}  


int main()
{
    printf("hello \n");
    const char washer_str[] = "FFFF08000000000000050D";
    uint8_t frame[128] = {0},len = 0;
    len = strlen(washer_str);
    
    HexStrToByte(washer_str,frame,len);
}